package com.ashapo;

import java.util.Objects;

/**
 * 课程类
 * @author Administrator
 */
public class Course implements Comparable<Course>{
	private final String name;
	
	private final String duration;
	
	private final int ctime;

	public Course(String name) {
		this.name = name;
		this.duration = "";
		this.ctime = 0;
	}

	/**
	 * 创建一个课程
	 * @param name 课程名称
	 * @param duration 课程时长
	 */
	public Course(String name, String duration) {
		this.name = name;
		this.duration = duration;
		this.ctime = 0;
	}

	public Course(String name, String duration, int ctime) {
		this.name = name;
		this.duration = duration;
		this.ctime = ctime;
	}

	public int getCtime() {
		return ctime;
	}
	
	

	public String getName() {
		return name;
	}

	@Override
	public int hashCode() {
		int hash = 3;
		hash = 97 * hash + Objects.hashCode(this.name);
		return hash;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Course other = (Course) obj;
		if (!Objects.equals(this.name, other.name)) {
			return false;
		}
//		if (!Objects.equals(this.duration, other.duration)) {
//			return false;
//		}
		return true;
	}

	/**
	 * 默认以名字进行排序,用于ArrayList数组sort
	 * @param o
	 * @return 
	 */
	@Override
	public int compareTo(Course o) {
		return this.name.compareTo(o.name);
	}
}